@extends('manage.layout')

@section('content')
    <div class="content">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                登录日志
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li><a href="#">log</a></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">内容</h3>
                        </div>
                        <div class="box-body">
                            <table class="table table-bordered table-hover"  style=" text-align: center;">
                               <tr>
                                    <th style="text-align: center;">ID</th>
                                    <th style="text-align: center;">登录时间</th>
                                    <th style="text-align: center;">登录用户</th>
                                    <th style="text-align: center;">角色</th>
                                    <th style="text-align: center;">ip</th>
                                </tr>
                                @foreach($log as $l)
                                    <tr>
                                        <td>{{ $l['id'] }}</td>
                                        <td>{{ $l['create_time']}}</td>
                                        <td>{{ $l['username']}}</td>
                                        <td>{{ App\Model\Role::find($l['role_id'])['name'] }}</td>
                                        <td>{{ long2ip($l['ip'])}}</td>
                                    </tr>
                                @endforeach
                            </table>
                        </div>
                        <div calss="pages" style="text-align: center;">
                            {{ $log->links() }}
                        </div>

                        <!-- /.box -->
                    </div>

                    <!-- /.row -->

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
@stop
@section('script')
    <script>
        function deleteAdmin(id) {
            layer.confirm('删除后不可恢复，是否继续?', {
                btn:['确定','取消']
            },function() {
                $.ajax({
                    url: '/system/admin/delAdmin',
                    type: "GET",
                    data: {id:id},
                    dataType: "json",
                    success: function(res) {
                        console.log(res);
                        if(res.error == 0) {
                            window.location.href = "/system/admin";
                            layer.msg(res.msg,{icon:1});
                        }
                        else {
                            layer.msg(res.msg,{icon:2});
                        }
                    },
                    error:function(){
                        layer.msg('ERROR');
                    }
                });
            });
        }
        //禁用,启用
        function setStatus(id,status) {
            $.ajax({
                url: '/system/admin/setStatus',
                type: "GET",
                data: {id:id,status:status},
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    if(res.error == 0) {
                        window.location.href=window.location.href;
                        layer.msg(res.msg, {time:1500, icon:1})
                    }
                    else {
                        layer.msg(res.msg, {time:1500, icon:2})
                    }
                }
            });
        }
    </script>
@stop
